
DEFINE VARIABLE doscmd AS CHARACTER  NO-UNDO.
DEFINE VARIABLE filetitle AS CHARACTER format "x(26)"  NO-UNDO initial "wo_nbr,rmks,qty_rjct,date".
DEFINE VARIABLE printtitle AS logical  NO-UNDO initial yes.
DEFINE VARIABLE vdate AS DATE       NO-UNDO.


assign vdate = today.
for first code_mstr no-lock where code_fldname =  "HKR3003" and code_value = "DATE":
    assign vdate = date(code_cmmt).
end.

FOR first code_mstr  NO-LOCK WHERE code_fldname = "HKR3003" and code_value = 'outpath'  :
END.
if avail code_mstr then do:
/*  doscmd = "Rar.exe a  -ep -ag -tk " + code_cmmt + "R3003.rar " +   code_cmmt + "R3003*.csv".  */
/*  dos silent  value(doscmd).                                                                   */
 doscmd = code_cmmt + "R3003.csv".
/*  message doscmd.  */
end.
if search(doscmd) = ? or search(doscmd) = "" then do:
    assign printtitle = yes.
end.
if search(doscmd) = ? then do:
    output to value(doscmd)  .
    assign printtitle = yes.
end.
else do:
    output to  value(doscmd)  .
end.
if printtitle  then
    put filetitle skip.



FOR EACH tr_hist NO-LOCK WHERE tr_type = "RCT-UNP" and tr_effdate >= 7/1/2008 and tr_effdate >= vdate - 60 and tr_effdate <= vdate and tr_rmks >= "W" :

    export delimiter "," tr_so_job tr_rmks tr_qty_loc string(year(tr_effdate),"9999") + "-" + string(month(tr_effdate),"99") + "-" + string(day(tr_effdate),"99").

END.
output close.

for first code_mstr exclusive-lock where code_fldname =  "HKR3003" and code_value = "lastrun":
end.
if avail code_mstr then do:
     assign code_cmmt = string(today) + " " + string(time,"HH:MM:SS" )
        code_user1 = "OK".
end.
else do:
    create code_mstr.
    assign code_fldname = "HKR3003"
           code_value = "lastrun"
           code_cmmt = string(today) + " " + string(time,"HH:MM:SS" )
           code_user1 = "OK".
end.

QUIT.
